const mongoose = require("mongoose");

async function connectToDatabase(uri) {
  if (!uri) {
    throw new Error("MONGODB_URI 未配置");
  }
  mongoose.set("strictQuery", true);
  await mongoose.connect(uri, {
    dbName: undefined,
  });
  return mongoose.connection;
}

module.exports = { connectToDatabase };
